package map;

import java.util.HashMap;
import java.util.Map;

public class MapDemo1 {
    public static void main(String[] args) {
        Map<String,Integer> a=new HashMap<>();
        Integer value=a.put("语文",98);//第一次存入key，返回值为null
        System.out.println(value);
        a.put("数学",100);
        a.put("英语",99);
        a.put("物理",80);
        a.put("化学",90);
        System.out.println(a);

        value=a.put("语文",100);//第二次存入key，返回值为原被替换的value
        System.out.println(value);
        value=a.get("语文");
        System.out.println(value);
        int size=a.size();
        System.out.println("列表里元素个数为"+size);
        value=a.remove("数学");
        System.out.println(a);
        System.out.println(value);
        //判断
        System.out.println(a.isEmpty());
        System.out.println(a.containsKey("语文"));
        System.out.println(a.containsValue(100));

        a.clear();//清空集合
    }
}
